#include <stdio.h>
#include <stdlib.h>

struct Node {
    int data;
    struct Node* next;
};

struct Node* createList(int n) {
    struct Node* head = NULL;
    struct Node* tail = NULL;
    for (int i = 0; i < n; i++) {
        struct Node* inp = (struct Node*)malloc(sizeof(struct Node));
        scanf("%d", &inp->data);
        if (head == NULL)
            head = inp;
        else
            tail->next = inp;
        tail = inp;
    }
    tail->next = NULL;
    return head;
}
void printList(struct Node* head) {
    for (struct Node* it = head; it; it = it->next) {
        printf("%d->", it->data);
    }
    printf("NULL\n");
}
struct Node* insertList(struct Node* head, int value, int pos) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->data = value;
    if (pos == 1) {
        newNode->next = head;
        return newNode;
    }
    struct Node* it = head;
    for (int i = 0; i < pos - 2; i++) it = it->next;
    if (it->next != NULL) newNode->next = it->next;
    it->next = newNode;
    return head;
}
int main() {
    int n;
    scanf("%d", &n);

    struct Node* head = createList(n);
    printList(head);

    int value, pos;
    scanf("%d%d", &value, &pos);

    head = insertList(head, value, pos);
    printList(head);

    return 0;
}